Skip to content

feat: add createCacheHandler for middleware-style cache origins#72

Merged
aui merged 3 commits into
mainfrom
feat/middleware-cache-handler
Jun 17, 2026
Merged

feat: add createCacheHandler for middleware-style cache origins#72
aui merged 3 commits into
mainfrom
feat/middleware-cache-handler

Conversation

@aui

@aui aui commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add resolveWithCache and createCacheHandler for in-process origin handlers (e.g. middleware next()), with phase-aware error handling: miss throws propagate, revalidation failures become 5xx for stale-if-error.
  • Refactor createFetch to delegate to resolveWithCache; outbound HTTP behavior unchanged.
  • Add unit tests in origin.test.ts and resolve.test.ts; document API split in README.

Test plan

  • pnpm test (301 tests)
  • pnpm build

Extract resolveWithCache as the shared caching core, add phase-aware
origin invocation for in-process handlers, and refactor createFetch to
use the same path.
@changeset-bot

changeset-bot Bot commented Jun 17, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 6a63c23

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@web-widget/shared-cache Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codecov

codecov Bot commented Jun 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.95652% with 14 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/index.ts 0.00% 8 Missing ⚠️
src/origin.ts 97.19% 3 Missing ⚠️
src/resolve.ts 98.93% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

@aui aui merged commit 2aeb468 into main Jun 17, 2026
3 checks passed
@aui aui deleted the feat/middleware-cache-handler branch June 17, 2026 07:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant